package com.zy.nft_system.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 这是那头猪？
 * @version 1.0
 * @description: TODO
 * @date 2022/10/2 18:52
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Value("${imgPath}")
    private String imgPath;

    @Resource
    JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/user/regist","/user/login","/Qqntiqueauth/listCollectionStatus1", "/Carouselmap/queryCarouselmapList", "/Announcement/queryAnnouncementList",  "/Qqntiqueauth/queryCoolectionById", "/user/uploadUserImg", "/user/setUserImg")
                .excludePathPatterns( "/**/*.html", "/**/*.js", "/**/*.css", "/**/*.woff", "/**/*.ttf");  //
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //指定静态资源路径
        registry.addResourceHandler("/User-Img/**").addResourceLocations("file:"+imgPath);
    }

}
